'''
Created on 15 mai 2009

@author: tmeedendorp
'''

class ProcessFile:
    
    def __init__(self, filename, lineComputors):
        self.filename = filename
        self.lineComputors = lineComputors
    
    def run(self):
        file = open(self.filename)
        try:
            lineNumber = 1
            while 1:
                line = file.readline()
                if line == '':
                    break
                for word in line.split():
                    #encodedWord = word.decode("utf-8")
                    for lineComputor in self.lineComputors:
                        lineComputor.processWord(word.lower().strip(' \t\n,.()'), lineNumber)
                lineNumber+=1
            print("Finished processing document \""+self.filename+"\"")
        finally:
            file.close()
    

